<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>博客信息管理</title>
	<link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" th:href="@{/bootstrap-3.3.7-dist/css/bootstrap.min.css}">
    <link href="css/common.css" rel="stylesheet" th:href="@{/css/common.css}">
	<link href="tagsinput/jquery.tagsinput.css.css" rel="stylesheet" th:href="@{/tagsinput/jquery.tagsinput.css}">
    <script type="text/javascript" src="js/jquery-1.12.4.min.js" th:src="@{/js/jquery-1.12.4.min.js}"></script>
    <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js" th:src="@{/bootstrap-3.3.7-dist/js/bootstrap.min.js}"></script>
    <script src="/My97DatePicker/WdatePicker.js" type="text/javascript" th:src="@{/My97DatePicker/WdatePicker.js}"></script>
    <script src="jquery-validation-1.14.0/lib/jquery.js" th:src="@{/jquery-validation-1.14.0/lib/jquery.js}"></script>
    <script src="jquery-validation-1.14.0/dist/jquery.validate.min.js" th:src="@{/jquery-validation-1.14.0/dist/jquery.validate.min.js}"></script>
	<!-- 确保引入的js文件路径正确 -->
	<script th:src="@{/ckeditor/ckeditor.js}"></script>
	<script src="tagsinput/jquery.tagsinput.js" th:src="@{/tagsinput/jquery.tagsinput.js}"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
			rules : {
				title: {
					required : true
				},
				typeId: {
					required : true
				},
				blogLabels: {
					required : true
				},
				content: {
					required : true
				},
				lookNum: {
					required : true
				},
				createTime: {
					required : true
				},
			},
			messages : {
				title: {
					required : "标题必填"
				},
				typeId: {
					required : "博客类型必填"
				},
				blogLabels: {
					required : "博客标签必填"
				},
				content: {
					required : "内容必填"
				},
				lookNum: {
					required : "浏览量必填"
				},
				createTime: {
					required : "发布时间必填"
				},
			}
		})
		});


	</script>
</head>
<body>
	<div class="container"><br>
	<form id="inputForm" action="/admin/cms/blogs/save" method="post" class="form-horizontal"  enctype="multipart/form-data">
		<input type="hidden" name="id" th:value="${blogs.id}" />
			
			<div class="form-group" id="roleSelect">
				<label for="title" class="col-sm-1 control-label">标题<b class="error">*</b></label>
   				<div class="col-sm-6">
			
						 <input name="title" th:value="${blogs.title}" maxlength="255" class="form-control"/>
				</div>
			</div>
			
			<div class="form-group" id="roleSelect">
				<label for="typeId" class="col-sm-1 control-label">博客类型<b class="error">*</b></label>
   				<div class="col-sm-6">
					<select name="typeId" class="form-control">
						<option th:each="blogType:${types}" th:selected="${blogType.id==blogs.typeId}" th:value="${blogType.id}" th:text="${blogType.name}"></option>
					</select>
				</div>
			</div>
			
			<div class="form-group" id="roleSelect">
				<label for="blogLabels" class="col-sm-1 control-label">博客标签<b class="error">*</b></label>
   				<div class="col-sm-6">
					<div class="checkbox">
						<input id="blogLabels" name="blogLabels" th:value="${blogs.blogLabels}">
				      </div>
				</div>
			</div>

			
			<div class="form-group" id="roleSelect">
				<label for="smallContent" class="col-sm-1 control-label">简介<b class="error">*</b></label>
   				<div class="col-sm-6">
					<textarea  name="smallContent" class="form-control"  rows="5" cols="" th:text="${blogs.smallContent}"></textarea>
				</div>
			</div>
			
			<div class="form-group" id="roleSelect">
				<label for="content" class="col-sm-1 control-label">内容<b class="error">*</b></label>
   				<div class="col-sm-10">
					<textarea name="content" id="content" rows="200" cols="80" th:text="${blogs.content}"></textarea>
					<!--<script type="text/javascript">
					 CKEDITOR.replace( 'content',{
			        	 "toolbar":"Full",
			        	  "height": 300
			         } );
					</script>-->
				</div>
			</div>
			
			<div class="form-group" id="roleSelect" style="display: none;">
				<label for="lookNum" class="col-sm-1 control-label">浏览量<b class="error">*</b></label>
   				<div class="col-sm-6">
			
						 <input name="lookNum" th:value="${blogs.lookNum}" maxlength="255" class="form-control"/>
				</div>
			</div>
			
			<div class="form-group" id="roleSelect">
				<label for="firstname" class="col-sm-1 control-label"></label>
   				<div class="col-sm-6">
					<button class="btn btn-success" type="submit">保 存</button>
					<button class="btn btn-inf" type="button" onclick="javascript:history.go(-1);">返 回</button>
				</div>
			</div>
	</form>
	</div>
</body>
<script th:src="@{/ueditor/ueditor.config.js}"></script>
<script th:src="@{/ueditor/ueditor.all.min.js}"></script>
<script th:src="@{/ueditor/lang/zh-cn/zh-cn.js}"></script>
<script>

	$("#blogLabels").tagsInput();

	var ue = UE.getEditor('content',{
		toolbars: [
			[
				'undo', //撤销
				'redo', //重做
				'bold', //加粗
				'indent', //首行缩进
				'snapscreen', //截图
				'italic', //斜体
				'underline', //下划线
				'strikethrough', //删除线
				'subscript', //下标
				'fontborder', //字符边框
				'superscript', //上标
				'formatmatch', //格式刷
				'source', //源代码
				'blockquote', //引用
				'pasteplain', //纯文本粘贴模式
				'horizontal', //分隔线
				'removeformat', //清除格式
				'cleardoc', //清空文档
				'insertcode', //代码语言
				'fontfamily', //字体
				'fontsize', //字号
				'paragraph', //段落格式
				'simpleupload', //单图上传
				'insertimage', //多图上传
				'link', //超链接
				'emotion', //表情
				'spechars', //特殊字符
				'searchreplace', //查询替换
				'justifyleft', //居左对齐
				'justifyright', //居右对齐
				'justifycenter', //居中对齐
				'justifyjustify', //两端对齐
				'forecolor', //字体颜色
				'backcolor', //背景色
				'insertorderedlist', //有序列表
				'insertunorderedlist', //无序列表
				'fullscreen', //全屏
				'rowspacingtop', //段前距
				'rowspacingbottom', //段后距
				'pagebreak', //分页
				'imageleft', //左浮动
				'imageright', //右浮动
				'imagecenter', //居中
				'lineheight', //行间距
				'autotypeset', //自动排版
			]
		],
		autoHeightEnabled: false,
		autoFloatEnabled: true,
		initialFrameHeight:500,
		initialFrameWeight:null,

	});

	UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
	UE.Editor.prototype.getActionUrl = function(action) {
		if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'listimage') {
			return '/ueUploadController/upload?type=image';
		}if(action == 'uploadvideo'){
			return '/ueUploadController/upload?type=video';
		}if(action == 'uploadfile'){
			return '/ueUploadController/upload?type=video';
		} else {
			return this._bkGetActionUrl.call(this, action);
		}
	}


</script>
</html>